package com.bp.exam.util;

import com.bianmaba.spring.data.jpa.domain.Result;

public class ResultUtil {
    public static final String SUCCESS_MSG = "查询成功";

    public static Result returnFail(String msg) {
        Result result = new Result();
        result.setResult(msg);
        result.setSuccess(false);
        return result;
    }

    public static Result returnSuccess(String msg, Object data) {
        Result result = new Result();
        result.setResult(msg);
        result.setData(data);
        result.setSuccess(true);
        return result;
    }
    public static Result returnSuccess(String msg) {
        return returnSuccess(msg,null);
    }

    public static Result returnQuery(Object data) {
        return returnSuccess(SUCCESS_MSG, data);
    }

    public static Result returnObject(Boolean success, String msg, Object data) {
        Result result = new Result();
        result.setData(data);
        result.setResult(msg);
        result.setSuccess(success);
        return result;
    }

    public static Result returnObject(Boolean success, String msg) {
        return returnObject(success, msg, null);
    }
}
